<?php
namespace Home\Controller;
use Think\Controller;
class ListemploymentController extends Controller {
  // 后台登录页
    public function index(){
        if(isset($_SESSION['admin'])){
            $info = D("info");
            $position = D("position");
            $infoList = $info->select();
            for($i=0; $i < count($infoList); $i++){
                $position_id = $infoList[$i]['position_id'];              
                $positionname = $position->where("id='$position_id'")->field('name')->select();
                $infoList[$i]['position'] = $positionname[0]['name'];
            }

            $this->assign('list',$infoList); 
            $this->display();           
        }else{

            $url = 'http://localhost/person/index.php/Home/Index/index';
            header("location: $url");
        }
    }


     // 管理页面首页
    public function manage(){
        if(!isset($_SESSION['admin']) || !$_SESSION['admin']){
            $url = 'http://localhost/person/index.php/Home/Index';
            header("location: $url");
        }else{                    
            $this->display();
        }
    }
      //退出
    public function doLogout(){
        $_SESSION = array();
        if(isset($_COOKIE[session_name()])){
            setcookie(session_name(),'',time()-1,'/');
        }
        session_destroy();
        $this->redirect('Index/index');
    }
}